package offer;

/**
 * @author Jonny Long
 * @date 2021/3/19 21:49
 */
public class Solution15 {
    // you need to treat n as an unsigned value
    public int hammingWeight(int n) {
        int cnt = 0;
        while (n != 0) {
            if (n % 10 == 1) {
                cnt++;
            }
            n /= 10;
        }
        return cnt;
    }
}
